package com.hmall;

import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.annotation.AnnotationConfigUtils;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author gonghuaiguo
 */
public class TestBeanFactory {

    public static void main(String[] args) {

        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();

        AbstractBeanDefinition beanDefinition = BeanDefinitionBuilder.genericBeanDefinition(Config.class).setScope("singleton").getBeanDefinition();
        beanFactory.registerBeanDefinition("config",beanDefinition);
        System.out.println(beanFactory.getBean(Config.class));

//        AnnotationConfigUtils.registerAnnotationConfigProcessors(beanFactory);



    }


}
@Configuration
 class Config{

    @Bean
    public String bean1(){
        return "bbb";
    }

    @Bean
    public String bean2(){
        return "bbb2";
    }
}